package easy;

public class Solution_1013 {
    public int bitwiseComplement(int n) {
        if (n==0) return 1;
        int num = 0, bit = 0;
        while (n > 0) {
            int mod = n % 2;
            if (mod == 0) {
                num += 1 << bit;
            }
            n = n >> 1;
            bit++;
        }
        return num;
    }

    public static void main(String[] args) {
        Solution_1013 model = new Solution_1013();
        System.out.println(model.bitwiseComplement(1));
        System.out.println(model.bitwiseComplement(2));
        System.out.println(model.bitwiseComplement(5));
        System.out.println(model.bitwiseComplement(7));
        System.out.println(model.bitwiseComplement(10));
        System.out.println(1 << 0);
        System.out.println(4 << 0);
    }
}
